

package com.hazelcast.internal.config.yaml;

import com.hazelcast.internal.yaml.YamlNode;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Empty {@link NodeList} implementation. Used by {@link YamlElementAdapter#getChildNodes()}
 * when wrapping {@link YamlNode}s with no children.
 */
final class EmptyNodeList implements NodeList {
    private static final NodeList INSTANCE = new EmptyNodeList();

    private EmptyNodeList() {
    }

    /**
     * Returns the singleton instance of this class
     *
     * @return an empty {@link NodeList}
     * @see #INSTANCE
     */
    static NodeList emptyNodeList() {
        return INSTANCE;
    }

    @Override
    public Node item(int index) {
        return null;
    }

    @Override
    public int getLength() {
        return 0;
    }
}
